
let curUnionID = null;
let curUid = null;
let curDay = null;

function createList(pageNo = 1, pageSize = 10) {
    let matchData = {};
    matchData.uid = curUid;
    matchData["unionID"] = curUnionID;
    matchData["day"] = curDay;
    var start = (pageNo - 1) * pageSize;
    apiAdminGetRecord("userPayDetailModel", start, pageSize, matchData, function (data) {
        if (data.code === 0) {
            if (data.code === 0) {
                setTimeout(() => {
                    $('#dataList').bootstrapTable('load', data.msg);
                }, 200)

            }
        }
    });
}

$(document).ready(function () {
    var parameters = parseQueryString(window.location.href);
    curUnionID = parameters.unionID;
    curUid = parameters.uid;
    curDay = parameters.day;
    //数据表格初始化
    $('#dataList').bootstrapTable({
        showRefresh: true,
        striped: true, // 是否显示行间隔色
        pageNumber: 1, // 初始化加载第一页
        pagination: true, // 是否分页
        sidePagination: 'server', // server:服务器端分页|client：前端分页
        pageSize: 10, // 单页记录数
        pageList: [10, 20, 30],
        theadClasses: "thead-light",//这里设置表头样式
        totalField: "totalCount",
        smartDisplay: false,
        buttonsClass: 'light',
        buttonsPrefix: 'btn',
        dataField: "recordArr",
        maintainSelected: true,
        showRefresh: false,// 刷新按钮
        onPageChange: function (number, size) {
            createList(number, size);
        },
        queryParams: function (params) { // 上传服务器的参数
            var temp = {//如果是在服务器端实现分页，limit、offset这两个参数是必须的
                limit: params.limit, // 每页显示数量
                offset: params.offset, // SQL语句起始索引
            };
            return temp;
        },
        columns: [{
            title: 'id',
            field: '_id',
            visible: false
        },
        {
            title: '用户ID',
            width: 100,
            align: "center",
            valign: "middle",
            field: 'uid',
        }, {
            title: '昵称',
            width: 100,
            align: "center",
            valign: "middle",
            field: 'nickname',

        }, {
            title: '联盟ID',
            width: 100,
            align: "center",
            valign: "middle",
            field: 'unionID',
            sortable: true,
            order: "asc",

        }, {
            title: '数量',
            width: 150,
            align: "center",
            valign: "middle",
            field: 'count',
        }, {
            title: '游戏类型',
            width: 100,
            align: "center",
            valign: "middle",
            field: 'gameType',
            formatter: changeTypeMatter
        },
        {
            title: '时间',
            width: 150,
            align: "center",
            valign: "middle",
            field: 'createTime',
            formatter: dateMatter
        }]
    });
    $('#dataList').bootstrapTable('hideLoading');
    createList(1);
});



function dateMatter(value, row, index) {
    return new Date(value).toLocaleString();
}

function scoreMatter(value, row, index) {
    if (value) {
        return value.toFixed(2);
    } else {
        return 0;
    }

}

function changeTypeMatter(value, row, index) {

    if (value >= 1) {
        return enumeration.gameName[value]
    }
    else {
        return "未设置"
    }
}